package web.action;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;

import web.handle.AddUserBean;

import ejb.entity.User;
import ejb.manager.UserManager;

@ManagedBean
public class AddUserAction {
	@EJB
	private UserManager usermanager;
	
	@ManagedProperty(value="#{addUserBean}")
	private AddUserBean addUser;
	
	public AddUserAction(){}
	
	public AddUserBean getAddUser() {
		return addUser;
	}

	public void setAddUser(AddUserBean addUser) {
		this.addUser = addUser;
	}

	public String check(){
		User u = usermanager.createUser(addUser.getUser_name(), addUser.getLast_name(), addUser.getFirst_name(), addUser.getPassword(), addUser.getEmail());
		if(u == null) return "defeat";
		else return "success";
	}
}
